home *** CD-ROM | disk | FTP | other *** search
/ Corel Professional Photos 164: Ocean Life / Corel Professional Photos - 1994 - 164 - Ocean Life.ISO / drwmodel / mrktdraw.mst < prev    next >
Text File  |  1993-09-16  |  28KB  |  767 lines

  1. '' $Keywords: update.mst 1.7 28Jul93 10:12am$ $nokeywords$
  2. '**************************************************************************
  3. '*                       CorelDRAW! 4 Update script
  4. '**************************************************************************
  5. ''    Date         Name                Reason
  6. ''-------------------------------------------------------------------------
  7. '' JUL 14    1993    Ibrahim Sallam                Create
  8.  
  9. '$INCLUDE 'setupapi.inc'
  10.  
  11. ''C functions
  12. DECLARE SUB                InitializeInstall LIB "mscuistf.dll" (hInstance%, hMainWind% )
  13. DECLARE SUB                ShutDownInstall LIB "mscuistf.dll"
  14. DECLARE SUB                RegisterFont LIB "mscuistf.dll" (szFOTName$, szTTFName$) 
  15. DECLARE SUB                FileChangeString LIB "mscuistf.dll" (szFile1$, szFile2$, szString1$, szString2$)
  16. DECLARE SUB                FRecalcOptFiles LIB "mscuistf.dll" (iType%, szNeeds$)
  17. DECLARE FUNCTION    FIsDrawExist LIB "mscuistf.dll" (szFileName$, szDest$) AS INTEGER
  18. DECLARE FUNCTION    IsSectionKeyExist LIB "mscuistf.dll" (szSectionName$, szKeyName$) AS INTEGER
  19. DECLARE SUB             FAddFileToCopyList LIB "mscuistf.dll" (AppendSect$, Section$, FilterName$, SourceDir$, FiltersDir$) 
  20. DECLARE SUB                CommentIniSection LIB "mscuistf.dll" (szFileName$, szTempFile$, szSection$, szPath$ )
  21. DECLARE FUNCTION    GetFilenameFromPath LIB "mscuistf.dll" (szPath$) AS INTEGER
  22. DECLARE FUNCTION    IsTTFEnabled LIB "mscuistf.dll" AS INTEGER
  23. DECLARE FUNCTION     FGetBootDrive LIB "mscuistf.dll" AS INTEGER
  24. DECLARE FUNCTION    FModifyFile LIB "mscuistf.dll" (szFileName$, szList$, szWhere$) AS INTEGER
  25. DECLARE FUNCTION    IsWinForWorkgroups LIB "mscuistf.dll" AS INTEGER
  26.  
  27. '$INCLUDE 'setupvar.inc'
  28.  
  29. ''Strings for loading string resources
  30. GLOBAL szString$
  31. CONST     STRINGLEN =    128
  32. szString$ = string$( STRINGLEN+1, 32 )
  33.  
  34. ''setup main window
  35. ''CONST LOGO                            = 9100            ''must match the constant in dialogs.h
  36. CONST LOGO3                            = 9115            ''must match the constant in dialogs.h
  37. SetTitle TR_TITLE
  38. SetBitmap "mscuistf.dll", LOGO3
  39. ''SetBitmap "mscuistf.dll", LOGO
  40. InitializeInstall hinstFrame(), HwndFrame()        ''corel style buttons; max window
  41.  
  42. '$INCLUDE 'msdetect.inc'
  43.  
  44. '''$DEFINE DEBUG  ''Define for script development/debugging
  45.  
  46. ''Dialog ID's
  47. ''Note: These constants MUST match the constants in dialogs.h
  48. CONST DRAWWELCOME               =    9900
  49. CONST DRAWASKQUIT                  =    9901
  50. CONST DRAWDESTPATH                  =    9902
  51. CONST DRAWERROREXITFAILURE=    9903
  52. CONST DRAWEXITQUIT                  =    9904
  53. CONST DRAWEXITSUCCESS         =    9905
  54. CONST DRAWTOOBIG                      =    9906
  55. CONST DRAWERRORBADPATH       =    9907
  56. CONST DRAWWAIT                          =    9908
  57. CONST DRAWABOUT                      =    9909
  58. CONST DRAWASKINSTALL              =    9910
  59. CONST DRAWDESTPATHWARNING =    9911
  60. CONST BILLBOARD                      =    9912
  61. CONST DRAWSUCCESS         =    9913
  62. CONST DRAWWELCOMEHELP         =    9914
  63. CONST DRAWWAITCONFIGER         =    9915
  64. CONST DRAWSHARE           =    9916
  65. CONST DRAWSHAREHELP       =    9917
  66. CONST DRAWERRORDRAWEXIST    = 9920
  67.  
  68. CONST FALSE    = 0
  69. CONST TRUE    = 1
  70.  
  71. ''Constants representing each line in the custinst dialog
  72. CONST DRAW          = 1
  73. CONST CHART         = 2
  74. CONST SHOW            = 3
  75. CONST PHOTO            = 4
  76. CONST MOVE            = 5
  77. CONST TRACE            = 6
  78. CONST MOSAIC        = 7
  79. CONST SCANNERS  = 8
  80. CONST FILTERS        = 9            ''Does not have custom dialog
  81. CONST FONTTT        = 10
  82. CONST NUMCUST      = FONTTT
  83. CONST MAIN            = NUMCUST + 1
  84. CONST NUMGROUPS    = MAIN
  85.  
  86. GLOBAL DrivesList$            ''experemental variable for the drives list
  87. DrivesList$ = "DrivesList"
  88. GLOBAL TempList$                '' Used for Temp lists
  89. TempList$ = "TempList"
  90. GLOBAL aszNEEDS$
  91. aszNEEDS$        = "FilesNeeds" 
  92.  
  93. GLOBAL bTooBig%
  94. bTooBig% = FALSE
  95. GLOBAL bBadPath%
  96. bBadPath% = FALSE
  97. GLOBAL bBack%
  98. bBack% = FALSE
  99.  
  100. GLOBAL DIR(NUMGROUPS) AS STRING        ''list of directories for main options
  101.  
  102. GLOBAL WINDIR$            ''Windows directory.
  103. GLOBAL WINSYSDIR$        ''Windows directory.
  104. GLOBAL WINDRIVE$        ''Windows drive letter.
  105. GLOBAL DEST$            ''destination directory.
  106. GLOBAL szFontDir$        ''directory for .ttf fonts
  107. GLOBAL bWindowsIsNetworked%
  108. GLOBAL bWindowsForWorkgroups%
  109. GLOBAL bMakeCorelSection% '' if not CorelGraphics4 section in win.ini, make one
  110. GLOBAL szWWinDir$        ''Writable Windows directory
  111.  
  112. GLOBAL TOOLGROUP$                    '' Group in which tools are to be installed
  113. TOOLGROUP$ = "Draw4 Working Model"
  114. ''Variables to fake subroutines with parameters
  115. GLOBAL Dialog%
  116. GLOBAL szTempVar$
  117.  
  118. ''Globals for WaitOn and WaitOff
  119. GLOBAL nWaiting%
  120. GLOBAL CursorSave%
  121.  
  122. GLOBAL SrcDir$                '' Directory where files can be found
  123. SrcDir$ = GetSymbolValue("STF_SRCDIR")
  124. GLOBAL InfFile$
  125.  
  126. ''local MSTest functions
  127. DECLARE SUB WaitOnBig
  128. DECLARE SUB WaitOn
  129. DECLARE SUB WaitOff
  130. DECLARE SUB SetDirectories
  131. DECLARE SUB AddFilesToCopyList
  132. DECLARE SUB CalculateRequiredSpace
  133. DECLARE SUB    WrapFileChangeString( szFile1$, szFile2$, szString1$, szString2$ )
  134. DECLARE SUB    WrapCommentIniSection( szFileName$, szTempFile$, szSection$, szPath$ )
  135. DECLARE    SUB    CheckBackupFile( szFile1$, szFile2$ )
  136. DECLARE FUNCTION CreateProgmanItem (szGroup$, szItem$, szCmd$, szOther$, cmo%) AS INTEGER
  137. DECLARE FUNCTION MakePath( szDir$, szFile$ ) AS STRING
  138. DECLARE FUNCTION MakeDir( szDir$ ) AS STRING
  139. DECLARE SUB AddRedistSection( szSection$)
  140.  
  141. INIT:
  142.     '' set waiting cursor
  143.     nWaiting% = 0
  144.     WaitOn
  145.  
  146.     ''Set default directory names
  147.     WINDIR$ = GetWindowsDir
  148.     WINSYSDIR$ = GetWindowsSysDir
  149.     WINDRIVE$ = MID$(WINDIR$, 1, 1)
  150.     OpenLogfile MakePath(WINDIR$, "MRKTDRAW.LOG"), 0
  151.     bWindowsForWorkgroups% = IsWinForWorkgroups
  152.     IF bWindowsForWorkgroups% THEN
  153.         WriteToLogFile "Windows For Workgroups >>>>"
  154.     ENDIF
  155.     InfFile$ = "MRKTDRAW.INF"
  156.     
  157.     bWindowsIsNetworked% = IsDriveNetwork( MID$(WINSYSDIR$,1,1) )
  158.     DEST$ = WINDRIVE$ + ":\"+"DRAW4"
  159.     IF bWindowsIsNetworked% THEN
  160.         szWWinDir$ = WINDIR$
  161.     ELSE
  162.         szWWinDir$ = WINSYSDIR$
  163.     ENDIF
  164.  
  165.     
  166. '' Some Info to the Log File
  167.     WriteToLogFile "Installing CorelDRAW! 4 (Working Model)"
  168.     IF bWindowsIsNetworked% THEN
  169.         WriteToLogFile TR_NETWINDOWS
  170.     ENDIF
  171.     
  172.     ''find and read .inf file
  173.     ReadInfFile GetSymbolValue("STF_CWDDIR") + InfFile$
  174.  
  175.     ''Get Drives List
  176.     GetValidDrivesList(DrivesList$)
  177.         
  178. '' Put up the Welcome dialog
  179. WELCOME:
  180.     WaitOff
  181.     Dialog% = DRAWWELCOME
  182.     sz$ = UIStartDlg( "mscuistf.dll", Dialog%, "FInfoDlgProc", DRAWWELCOMEHELP, "FHelpDlgProc" )
  183.     SELECT CASE sz$
  184.     CASE "CONTINUE"
  185.         UIPop 1
  186.     CASE "ABOUT"
  187.         Dialog% = DRAWABOUT
  188.         GOSUB INFO
  189.         GOTO WELCOME
  190.     CASE "REACTIVATE"
  191.         GOTO WELCOME
  192.     CASE ELSE
  193.         GOSUB ASKQUIT
  194.         GOTO WELCOME
  195.     END SELECT
  196.  
  197. GETDIR:
  198.  
  199.     GOSUB GetAppsMainDir
  200.     SetDirectories
  201.  
  202.     sz$ = UIStartDlg("mscuistf.dll", DRAWWAIT, "FModelessDlgProc", 0, "")
  203.     AddFilesToCopyList
  204.     UIPop 1
  205.     GOSUB ASKINSTALL
  206.  
  207. INSTALL:
  208.     WriteToLogFile "INSTALL:"
  209.     WaitOn
  210.     ''Make sure there is enough space for Updating CorelDRAW!
  211.     WaitOnBig
  212.     CalculateRequiredSpace
  213.  
  214.     IF bTooBig% THEN
  215.         Dialog% = DRAWTOOBIG
  216.         GOSUB INFO
  217.         GOSUB ASKQUIT
  218.         GOTO  GETDIR
  219.     ENDIF
  220.     
  221.     CheckBackupFile MakePath(WINDIR$,"win.ini"), MakePath(WINDIR$,"win.cor")
  222.     CheckBackupFile MakePath(WINDIR$,"reg.dat"), MakePath(WINDIR$,"reg.cor")
  223.     CheckBackupFile MakePath(WINDIR$,"progman.ini"), MakePath(WINDIR$,"progman.cor")
  224.  
  225.     ConfigDir$ = GetIniKeyString(TR_WIN_INI, "CorelGraphics4", "Dir")
  226.     IF ConfigDir$ <> "" THEN
  227.         IF DoesFileExist( MakePath(ConfigDir$, "CORELAPP.INI"), femExists ) = 0 THEN
  228.             bMakeCorelSection% = TRUE
  229.         ENDIF
  230.         IF DoesFileExist( MakePath(ConfigDir$, "CORELAPP.BAK"), femExists ) = 1 THEN
  231.             RemoveFile MakePath(ConfigDir$, "CORELAPP.BAK"), cmoForce
  232.         ENDIF        
  233.     ELSE
  234.         bMakeCorelSection% = TRUE
  235.     ENDIF
  236.  
  237.     CreateDir MakePath( DIR(MAIN), TR_AUTOBACK ), cmoNone
  238.  
  239.     ''Copy all the files over
  240.     WaitOff
  241.         WriteToLogFile "START CopyFilesInCopyList"
  242.         CopyFilesInCopyList
  243.         WriteToLogFile "END CopyFilesInCopyList"
  244.     WaitOn
  245.  
  246.         sz$ = UIStartDlg("mscuistf.dll", DRAWWAITCONFIGER, "FModelessDlgProc", 0, "")
  247.  
  248.         IF IsTTFEnabled = 1 THEN
  249.             WriteToLogFile "**** TTFEnabled ****"
  250.             '' Let's register the Symbols TTF,... FONTLIST1$ is an empty Symbole varaible
  251.               SetSymbolValue TempList$, "{}"
  252.                 MakeListFromSectionKeys TempList$, "WFN"
  253.                 FOR i% = 1 TO GetListLength(TempList$)
  254.                     szFileName$ = GetSectionKeyFilename( "WFN", GetListItem(TempList$, i%))
  255.                     index% = GetFilenameFromPath( szFileName$ )
  256.                     szFileName2$ = MID$( szFileName$, index%, LEN(szFileName$) - index% + 1 )
  257.                     IF MID$(szFileName2$, LEN(szFileName2$)-2) = "ttf" THEN
  258.                         szFOTName$ = MID$(szFileName2$,1,LEN(szFileName2$)-3) + "fot"
  259.                         RegisterFont MakePath(szWWinDir$,szFOTName$), MakePath(DIR(MAIN),TR_SYMBOLS+"\"+szFileName2$)
  260.                         temp% = GetTypeFaceNameFromTTF( MakePath(DIR(MAIN),TR_SYMBOLS+"\"+szFileName2$), szString$, STRINGLEN )
  261.                         IF temp% > 0 AND temp% < STRINGLEN THEN
  262.                             CreateIniKeyValue TR_WIN_INI, "fonts", szString$+" "+TR_TRUETYPE, UCASE$(szFOTName$), cmoOverWrite
  263.                         ENDIF
  264.                     ENDIF
  265.                 NEXT i%
  266.                 
  267.                 SetSymbolValue TempList$, "{}"
  268.                 MakeListFromSectionKeys TempList$, "DrawFonts"
  269.                     WriteToLOgFile "Adding DrawFonts"
  270.                 
  271.                 FOR nIndex% = 1 TO GetListLength(TempList$)
  272.                     Font$ = GetListItem(TempList$, nIndex%)
  273.                     szFileName$ = GetSectionKeyFilename("DrawFonts", Font$ )
  274.                     index% = GetFilenameFromPath( szFileName$ )
  275.                     szFileName2$ = MID$( szFileName$, index%, LEN(szFileName$) - index% + 1 )
  276.                     szFOTName$ = MID$(szFileName2$,1,LEN(szFileName2$)-3) + "fot"
  277.                     RegisterFont MakePath(szWWinDir$,szFOTName$), MakePath(DIR(FONTTT),szFileName2$)
  278.                     temp% = GetTypeFaceNameFromTTF( MakePath(DIR(FONTTT),szFileName2$), szString$, STRINGLEN )
  279.                     IF temp% > 0 AND temp% < STRINGLEN THEN
  280.                         CreateIniKeyValue TR_WIN_INI, "fonts", szString$+" "+TR_TRUETYPE, UCASE$(szFOTName$), cmoOverWrite
  281.                     ENDIF
  282.                     szString$ = string$( STRINGLEN+1, 32 )
  283.                     szFileName$ = ""
  284.                     szFileName2$ = ""
  285.                     szFOTName$ = ""
  286.                 NEXT nIndex%
  287.         ENDIF
  288.  
  289.  
  290.         IF bMakeCorelSection% THEN
  291.             CheckBackupFile MakePath(WINDIR$,"win.ini"), MakePath(WINDIR$,"win.cor")
  292.             CreateIniKeyValue TR_WIN_INI, "CorelGraphics4", "Dir", MakePath(DIR(MAIN), TR_CONFIG), cmoOverWrite
  293.         ENDIF            
  294.  
  295.         RUN( TR_REGLOAD_S + " " + MakePath(WINSYSDIR$, "OLE2.REG") )
  296.  
  297.         ini$ = MakePath( DIR(MAIN), TR_CONFIG+"\"+TR_CORELAPP_INI)
  298.         IF DoesFileExist( MakePath(ConfigDir$, "CORELAPP.BAK"), femExists ) = 0 THEN
  299.             oldini$ = MakePath( DIR(MAIN), TR_CONFIG+"\corelapp.bak")
  300.         ENDIF
  301.             CreateIniKeyValue ini$, "Config", "ProgramsDir", MakePath(DIR(MAIN),TR_PROGRAMS), cmoOverWrite
  302.             CreateIniKeyValue ini$, "Config", "DataDir", MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_DATA), cmoOverWrite
  303.             CreateIniKeyValue ini$, "Config", "CustomDir", MakePath(DIR(MAIN),TR_CUSTOM), cmoOverWrite
  304.                 OldDir$ = GetIniKeyString(oldini$, "Config", "DrawDir")
  305.                 IF OldDir$ <> "" THEN
  306.                     DIR(DRAW) = OldDir$
  307.                 ENDIF
  308.             CreateIniKeyValue ini$, "Config", "DrawDir", DIR(DRAW), cmoOverWrite
  309.                 OldDir$ = GetIniKeyString(oldini$, "Config", "ChartDir")
  310.                 IF OldDir$ <> "" THEN
  311.                     DIR(CHART) = OldDir$
  312.                 ENDIF
  313.             CreateIniKeyValue ini$, "Config", "ChartDir", DIR(CHART), cmoOverWrite
  314.                 OldDir$ = GetIniKeyString(oldini$, "Config", "ShowDir")
  315.                 IF OldDir$ <> "" THEN
  316.                     DIR(SHOW) = OldDir$
  317.                 ENDIF
  318.              CreateIniKeyValue ini$, "Config", "ShowDir", DIR(SHOW), cmoOverWrite
  319.                 OldDir$ = GetIniKeyString(oldini$, "Config", "PhotoPaintDir")
  320.                 IF OldDir$ <> "" THEN
  321.                     DIR(PHOTO) = OldDir$
  322.                 ENDIF
  323.              CreateIniKeyValue ini$, "Config", "PhotoPaintDir", DIR(PHOTO), cmoOverWrite
  324.                 OldDir$ = GetIniKeyString(oldini$, "Config", "MoveDir")
  325.                 IF OldDir$ <> "" THEN
  326.                     DIR(MOVE) = OldDir$
  327.                 ENDIF
  328.              CreateIniKeyValue ini$, "Config", "MoveDir", DIR(MOVE), cmoOverWrite
  329.                 OldDir$ = GetIniKeyString(oldini$, "Config", "TraceDir")
  330.                 IF OldDir$ <> "" THEN
  331.                     DIR(TRACE) = OldDir$
  332.                 ENDIF
  333.              CreateIniKeyValue ini$, "Config", "TraceDir", DIR(TRACE), cmoOverWrite
  334.                 OldDir$ = GetIniKeyString(oldini$, "Config", "MosaicDir")
  335.                 IF OldDir$ <> "" THEN
  336.                     DIR(MOSAIC) = OldDir$
  337.                 ENDIF
  338.              CreateIniKeyValue ini$, "Config", "MosaicDir", DIR(MOSAIC), cmoOverWrite
  339.             CreateIniKeyValue ini$, "Config", "FontsDir", MakePath(DIR(MAIN),TR_SYMBOLS), cmoOverWrite
  340.             CreateIniKeyValue ini$, "Config", "FiltersDir", DIR(FILTERS), cmoOverWrite
  341.                 OldStr$ = GetIniKeyString(oldini$, "Registration", "UserName")
  342.                 IF OldStr$ <> "" THEN
  343.                     UserName$ = OldStr$
  344.                 ELSE
  345.                     UserName$ = "Anyone"
  346.                 ENDIF
  347.             CreateIniKeyValue ini$, "Registration", "UserName", UserName$, cmoOverWrite
  348.                 OldStr$ = GetIniKeyString(oldini$, "Registration", "SerialNumber")
  349.                 IF OldStr$ <> "" THEN
  350.                     SerialNumber$ = OldStr$
  351.                 ELSE
  352.                     SerialNumber$ = "Working Model"
  353.                 ENDIF
  354.             CreateIniKeyValue ini$, "Registration", "SerialNumber", "Working Model", cmoOverWrite
  355.         ini$ = MakePath( DIR(MAIN), TR_CONFIG+"\"+TR_CORELPRN_INI)
  356.             CreateIniKeyValue ini$, "ColorPath", "CircuitPath", MakePath(DIR(MAIN),TR_CUSTOM), cmoOverwrite
  357.         ini$ = MakePath( DIR(MAIN), TR_CONFIG+"\"+TR_CORELFLT_INI)
  358.             CreateIniKeyValue ini$, "ColorPath", "CircuitPath", MakePath(DIR(MAIN),TR_CUSTOM), cmoOverWrite
  359.             CreateIniKeyValue ini$, "ColorPath", "CurvePath", MakePath(DIR(MAIN),TR_CUSTOM), cmoOverWrite
  360.             WrapCommentIniSection ini$, MakePath(Dir(MAIN),"___temp_"), "ImportFilters", MakePath(DIR(MAIN),TR_PROGRAMS+"\")
  361.             WrapCommentIniSection ini$, MakePath(Dir(MAIN),"___temp_"), "ExportFilters", MakePath(DIR(MAIN),TR_PROGRAMS+"\")
  362.             WrapCommentIniSection ini$, MakePath(Dir(MAIN),"___temp_"), "CorelAIExport", MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_DATA+"\")
  363.             WrapCommentIniSection ini$, MakePath(Dir(MAIN),"___temp_"), "CorelDXFExport", MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_DATA+"\")
  364.         ini$ = MakePath( DIR(MAIN), TR_CONFIG+"\"+TR_CORELFNT_INI)
  365.             WrapCommentIniSection ini$, MakePath(Dir(MAIN),"___temp_"), "Fonts", MakePath(DIR(MAIN),TR_SYMBOLS+"\")
  366.             WrapCommentIniSection ini$, MakePath(Dir(MAIN),"___temp_"), "Symbols", MakePath(DIR(MAIN),TR_SYMBOLS+"\")
  367.             CreateProgmanGroup TOOLGROUP$, "", cmoNone
  368.             ShowProgmanGroup  TOOLGROUP$, 1, cmoNone
  369. ''            nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, TR_RELEASENOTES, TR_WRITE_EXE + " " + MakePath(DIR(MAIN),TR_README_WRI), "", cmoOverwrite)
  370.     
  371. ''            WrapFileChangeString MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELDRW_REG), MakePath(DIR(MAIN),"___temp_"), TR_CORELDRW_EXE, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELDRW_EXE)
  372. ''            WrapFileChangeString MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELDRW_REG), MakePath(DIR(MAIN),"___temp_"), TR_CDROL140_DLL, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CDROL140_DLL)
  373. ''            RUN( TR_REGLOAD_S + " " + MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELDRW_REG) )
  374.             ini$ = MakePath(DIR(MAIN), TR_CONFIG+"\"+TR_CORELDRW_INI)
  375.                 CreateIniKeyValue ini$, "Config", "AutoBackupDir", MakePath(DIR(MAIN),TR_AUTOBACK), cmoOverwrite
  376.                 CreateIniKeyValue ini$, "Config", "TemplateDir", MakePath(DIR(DRAW),TR_TEMPLATE), cmoOverwrite
  377.             nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, TR_CORELDRAW, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELDRW_EXE),"", cmoOverwrite)
  378.  
  379.         UIPop 1 ''WAITCONFIGER Dialog
  380.  
  381. '' Installing SHARE
  382.         '' We don't want to install SHARE for Windows for Workgroups
  383.         IF bWindowsForWorkgroups% = FALSE THEN
  384.             Drive$ = CHR$( FGetBootDrive - 1 + ASC("A"))
  385.             ShareFile$ = FindFileInTree("SHARE.EXE", Drive$+":\")
  386.             IF ShareFile$ <> "" THEN
  387.                 SetSymbolValue "ShareLine", "{}"
  388.                 AddListItem "ShareLine", ShareFile$+" /L:500 /F:5100"
  389.                 IF bAutoexecModified% = FALSE THEN
  390.                     CopyFile Drive$+":\"+TR_AUTOEXEC_BAT, Drive$+":\"+TR_AUTOEXEC_COR, cmoOverwrite, 0
  391.                 ENDIF
  392. UPDATE:
  393.                 WaitOff
  394.                  sz$ = UIStartDlg( "mscuistf.dll", DRAWSHARE, "FButtonsDlgProc", DRAWSHAREHELP, "FHelpDlgProc" )
  395.             SELECT CASE sz$
  396.                 CASE "U"
  397.                         Res% = FModifyFile(Drive$+":\"+TR_AUTOEXEC_BAT, "ShareLine", "E")
  398.                     CASE "D"
  399.                         Res% = FModifyFile(Drive$+":\"+TR_AUTOEXEC_COR, "ShareLine", "E")
  400.                     CASE ELSE
  401.                         GOTO UPDATE
  402.                 END SELECT
  403.                         UIPop 1
  404.         
  405.             ENDIF '' IF ShareFile <> ""
  406.         ENDIF '' IF bWindowsForWorkgroups% = FALSE
  407.         
  408. '' User has completed run of setup or has unconditionally decided to quit
  409. QUIT:
  410.     WaitOff
  411.     '' On MSTest errors report "setup file corrupted" and abort
  412.     ON ERROR GOTO ERRQUIT
  413.  
  414.     IF ERR = 0 THEN
  415.         dlg% = DRAWEXITSUCCESS
  416.         szDlgProc$ = "FInfo0DlgProc"
  417.         WriteToLogfile TR_SETUPSUCCEEDED
  418.     ELSEIF ERR = STFQUIT THEN
  419.         dlg% = DRAWEXITQUIT
  420.         szDlgProc$ = "FInfo0DlgProc"
  421.         WriteToLogfile TR_SETUPQUIT
  422.     ELSE
  423.         dlg% = DRAWERROREXITFAILURE
  424.         szDlgProc$ = "FInfo0DlgProc"
  425.         WriteToLogfile TR_SETUPFAILED
  426.     ENDIF
  427.     
  428.  
  429. '' Put up one of the exit message dialog boxes
  430. QUITL1:
  431.     sz$ = UIStartDlg("mscuistf.dll", dlg%, szDlgProc, 0, "")
  432.     IF sz$ = "REACTIVATE" THEN
  433.         GOTO QUITL1
  434.     ENDIF
  435.  GOTO FINISH
  436.  
  437.  
  438. '' An error has occurred in MSTest. Tell the user and abort.
  439. ERRQUIT:
  440.     i% = DoMsgBox( "Files were corrupted, contact Corel Product Support!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  441.     WriteToLogfile "Setup Failed - files corrupted"
  442.     WriteToLogFile ""
  443. FINISH:
  444.     UIPopAll
  445.     ShutDownInstall
  446.     CloseLogFile
  447.     END
  448.  
  449. ASKINSTALL:
  450.     WaitOff
  451.     sz$ = UIStartDlg( "mscuistf.dll", DRAWASKINSTALL, "FInfoDlgProc", 0, "" )
  452.     SELECT CASE sz$
  453.     CASE "CONTINUE"
  454.         ''Do nothing
  455.     CASE "REACTIVATE"
  456.         GOTO ASKINSTALL
  457.     CASE ELSE
  458.         GOSUB ASKQUIT
  459.         GOTO ASKINSTALL
  460.     END SELECT
  461.     UIPop 1
  462. RETURN        ''return if the user want to update
  463.  
  464.  
  465. '' Display an information dialog
  466. '' Uses the global Dialog% to identify which dialog to display
  467. INFO:
  468.     WaitOff
  469.     sz$ = UIStartDlg( "mscuistf.dll", Dialog%, "FInfo0DlgProc", 0, "" )
  470.     SELECT CASE sz$
  471.     CASE "CONTINUE"
  472.         ''Do nothing
  473.     CASE "REACTIVATE"
  474.         GOTO INFO
  475.     CASE "EXIT"
  476.         GOSUB ASKQUIT
  477.         GOTO INFO
  478.     END SELECT
  479.     UIPop 1
  480. RETURN
  481.  
  482. '' The user has asked to quit - confirm his decision
  483. ASKQUIT:
  484.     WaitOff
  485.     sz$ = UIStartDlg("mscuistf.dll", DRAWASKQUIT, "FQuitDlgProc", 0, "")
  486.     SELECT CASE sz$
  487.     CASE "EXIT"
  488.         GOTO FINISH        '' OK. I know I shouldn't do that, but it's OK, It's the end of the script.
  489.     CASE "REACTIVATE"
  490.         GOTO ASKQUIT
  491.     CASE ELSE
  492.         ''Do nothing
  493.     END SELECT
  494.     UIPop 1
  495. RETURN
  496.  
  497. '***********************************************************************
  498. '***********************************************************************
  499. '**** Get CorelDRAW! 4 main directory                                ********************
  500. '***********************************************************************
  501. GetAppsMainDir:
  502.     WriteToLogFile "GetPath:"
  503.     bRet% = FIsDrawExist(TR_WIN_INI, szString$)
  504.     IF bRet% THEN  '' We have DRAW installed before (could be DRAW3 or DRAW4)
  505.         WriteToLogFile "String Found For Directory is"+ szString$
  506.         IF DoesFileExist( MakePath(szString$, "programs\coreldrw.exe"), femExists ) = 1 THEN
  507.             Dialog% = DRAWERRORDRAWEXIST
  508.             GOSUB INFO
  509.             ERR = STFERR
  510.             GOTO QUIT
  511.         ENDIF
  512.         DEST$ = szString$
  513.         DIR(MAIN) = DEST$
  514.         SetDirectories
  515.     ENDIF
  516.     Dialog% = DRAWDESTPATH
  517.     SetSymbolValue "EditTextIn", DEST$
  518.     SetSymbolValue "EditFocus", "END"
  519. GETPATHL1:
  520.     WaitOff
  521.     sz$ = UIStartDlg("mscuistf.dll", Dialog%, "FEditDlgProc", 0, "")
  522.     SELECT CASE sz$
  523.     CASE "CONTINUE"
  524.         WaitOn
  525.         olddest$ = DEST$
  526.         DEST$ = RTRIM$(LTRIM$(GetSymbolValue("EditTextOut")))
  527.         ''Validate new path.
  528.         IF DEST$ = "" OR IsDirWritable(DEST$) = 0 THEN
  529.             OldDialog% = Dialog%
  530.             Dialog% = DRAWERRORBADPATH
  531.             GOSUB INFO
  532.             Dialog% = OldDialog%
  533.             GOTO GETPATHL1
  534.         ENDIF
  535.  
  536.     CASE "REACTIVATE"
  537.         GOTO GETPATHL1
  538.     CASE "CANCEL", "BACK"
  539.         UIPop 1
  540.         bBack% = TRUE
  541.         RETURN
  542.     CASE ELSE
  543.         GOSUB ASKQUIT
  544.         GOTO GETPATHL1
  545.     END SELECT
  546.     WriteToLogFile TR_BASEDIR + DEST$
  547.     WriteToLogFile ""
  548.     UIPop 1
  549. RETURN
  550.  
  551.  
  552. '*************************************************************************
  553. '*************************************************************************
  554. '**** Add files to copy list according to the bUpdate flags **************
  555. '*************************************************************************
  556. '*************************************************************************
  557. SUB AddFilesToCopyList STATIC
  558.  
  559.         WriteToLogFile "AddFilesToCopyList"
  560.         WriteToLogFile "AddFilesToCopyList: DRAW"
  561.             AddSectionFilesToCopyList "DrawMain", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
  562.             AddSectionFilesToCopyList "DrawDraw", SrcDir$, DIR(DRAW)
  563. ''            AddSectionFilesToCopyList "DrawEhandler", SrcDir$, MakePath(DIR(DRAW), TR_EHANDLER)
  564.             AddSectionFilesToCopyList "DrawConfig", SrcDir$, MakePath(DIR(MAIN),TR_CONFIG)
  565.             AddSectionFilesToCopyList "DrawHelp", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
  566.             AddSectionFilesToCopyList "DrawTemplate", SrcDir$, MakePath(DIR(DRAW),TR_TEMPLATE)
  567.             AddSectionFilesToCopyList "DrawSamples", SrcDir$, MakePath(DIR(DRAW), TR_SAMPLES)
  568.             ''The Common Bullets should be always installed with DRAW     
  569.         WriteToLogFile "AddFilesToCopyList: WFN"
  570.             AddSectionKeyFileToCopyList "WFN", TR_COMMONBULLETS, SrcDir$, MakePath(DIR(MAIN),TR_SYMBOLS)
  571.         WriteToLogFile "AddFilesToCopyList: TTF"
  572.             AddSectionFilesToCopyList "DrawFonts", SrcDir$, DIR(FONTTT)
  573.  
  574.         WriteToLogFile "AddFilesToCopyList: MAIN & COMMON"
  575. ''            AddSectionFilesToCopyList "Main", SrcDir$, DIR(MAIN)
  576.             AddSectionFilesToCopyList "CommonDLL", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
  577.             AddSectionFilesToCopyList "CommonConfig", SrcDir$, MakePath(DIR(MAIN),TR_CONFIG)
  578.             AddSectionFilesToCopyList "Custom", SrcDir$, MakePath(DIR(MAIN),TR_CUSTOM)
  579.             AddSectionFilesToCopyList "ProgramData", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_DATA)
  580.             AddRedistSection "CommonRedist"
  581.  
  582.         WriteToLogFile "AddFilesToCopyList: FILTERS"
  583.             AddSectionFilesToCopyList "ImpFilters", SrcDir$, DIR(FILTERS)
  584. ''            AddSectionFilesToCopyList "ImpFiltersDrMoTr", SrcDir$, DIR(FILTERS)
  585. ''            AddSectionFilesToCopyList "ImpFiltersDrMoPhTr", SrcDir$, DIR(FILTERS)
  586.  
  587. ''            AddSectionFilesToCopyList "ExpFiltersDrPh", SrcDir$, DIR(FILTERS)
  588.  
  589.             
  590. END SUB
  591.  
  592. '**
  593. '** Purpose:
  594. '**     Removes the optional trailing "\"
  595. '** Arguments:
  596. '**     szDir$  - full directory path (with optional ending "\")
  597. '** Returns:
  598. '**     szDir$ without a trailing "\"
  599. '*************************************************************************
  600. FUNCTION MakeDir (szDir$) STATIC AS STRING
  601.     IF szDir$ <> "" THEN
  602.         IF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  603.             MakeDir = MID$( szDir$, 1, LEN(szDir$) - 1 )
  604.         ELSE
  605.             MakeDir = szDir$
  606.         ENDIF
  607.     ELSE
  608.         MakeDir = szDir$
  609.     ENDIF
  610. END FUNCTION
  611.  
  612.  
  613. '**
  614. '** Purpose:
  615. '**     Appends a file name to the end of a directory path,
  616. '**     inserting a backslash character as needed.
  617. '** Arguments:
  618. '**     szDir$  - full directory path (with optional ending "\")
  619. '**     szFile$ - filename to append to directory
  620. '** Returns:
  621. '**     Resulting fully qualified path name.
  622. '*************************************************************************
  623. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  624.     MakePath = MakeDir(szDir$) + "\" + szFile$
  625. END FUNCTION
  626.  
  627.  
  628. '** Make sure that the long wait dialog is displayed and the hourglass cursor
  629. '** are being used
  630. '*************************************************************************
  631. SUB WaitOnBig STATIC
  632.     IF nWaiting% = 0 THEN
  633.         CursorSave% = ShowWaitCursor()
  634.     ENDIF
  635.     IF nWaiting% <> 2 THEN
  636.         sz$ = UIStartDlg("mscuistf.dll", DRAWWAIT, "FModelessDlgProc", 0, "")
  637.     ENDIF
  638.     nWaiting% = 2
  639. END SUB
  640.  
  641.  
  642. '** Make sure that the hourglass cursor is being used
  643. '*************************************************************************
  644. SUB WaitOn STATIC
  645.     IF nWaiting% = 0 THEN
  646.         CursorSave% = ShowWaitCursor()
  647.         nWaiting% = 1
  648.     ENDIF
  649. END SUB
  650.  
  651.  
  652. '** Remove the long wait dialog if it is being displayed and reset the cursor
  653. '** back to normal if it was set to the hourglass icon
  654. '*************************************************************************
  655. SUB WaitOff STATIC
  656.     IF nWaiting% = 2 THEN
  657.         UIPop 1
  658.     ENDIF
  659.     IF nWaiting% <> 0 THEN
  660.         RestoreCursor CursorSave%
  661.     ENDIF
  662.     nWaiting% = 0
  663. END SUB
  664.  
  665.  
  666.  
  667. '** Wrapper function - should reduce size of code segment.
  668. '**
  669. '** FileChangeString replaces szString1$ in szFile1$ with szString2$.
  670. '** szFile2$ is a temporary file name.
  671. '*************************************************************************
  672. SUB    WrapFileChangeString( szFile1$, szFile2$, szString1$, szString2$ ) STATIC
  673.     FileChangeString szFile1$, szFile2$, szString1$, szString2$
  674. END SUB
  675.  
  676.  
  677. '** Wrapper function - should reduce size of code segment.
  678. '**
  679. '** CommentIniSection checks to see whether or not the files mentioned in
  680. '** szSection$ can be found in directory szPath$. If not, it sticks a ';'
  681. '** in front of that line of the ini file. Otherwise it makes sure there
  682. '** is not semi-colon commenting out that line.
  683. '** Note: this function is heavily dependent on the format of coreldrw.ini
  684. '*************************************************************************
  685. SUB    WrapCommentIniSection( szFileName$, szTempFile$, szSection$, szPath$ ) STATIC
  686.     CommentIniSection szFileName$, szTempFile$, szSection$, szPath$
  687. END SUB
  688.  
  689.  
  690. '** If the second file does not exist, backup szFile1$ as szFile2$
  691. '*************************************************************************
  692. SUB CheckBackupFile( szFile1$, szFile2$ ) STATIC
  693.     IF DoesFileExist(szFile2$,femExists) = 0 AND DoesFileExist(szFile1$,femExists) THEN
  694.         CopyFile szFile1$, szFile2$, cmoNone, 0
  695.     ENDIF
  696. END SUB
  697.  
  698.  
  699. '***********************************************************************
  700. '***********************************************************************
  701. '**** CalculateRequiredSpace on the destination disk    ******************
  702. '***********************************************************************
  703. SUB CalculateRequiredSpace STATIC
  704.  
  705.         WriteToLogFile "SUB CalculateRequiredSpace"
  706.         bTooBig% = FALSE
  707.         StillNeed& = GetCopyListCost(EXTRACOSTS$, aszNEEDS$, "")
  708.         IF StillNeed& THEN
  709.             bTooBig% = TRUE
  710.         ENDIF
  711.  
  712. END SUB
  713.  
  714. '*************************************************************************
  715. FUNCTION CreateProgmanItem (szGroup$, szItem$, szCmd$, szOther$, cmo%) STATIC AS INTEGER
  716.   szItemNew$ = szItem$
  717.   IF szOther$ <> "" THEN
  718.     szItemNew$ = szItem$ + "," + szOther$
  719.   END IF
  720.  
  721.   IF FCreateProgManItem(szGroup$, szItemNew$, szCmd$, cmo%) = 0 THEN
  722.         CreateProgmanItem = 1
  723.     ELSE
  724.         CreateProgmanItem = 0
  725.   END IF
  726. ''    szItemNew$ = ""
  727. END FUNCTION
  728.  
  729. '** Set the subdirectories to their default values.
  730. '*************************************************************************
  731. SUB SetDirectories STATIC
  732.     IF bWindowsIsNetworked% THEN
  733.         szFontDir$ = WINDIR$
  734.         szWWinDir$ = WINDIR$
  735.     ELSE
  736.         szFontDir$ = WINSYSDIR$
  737.         szWWinDir$ = WINSYSDIR$
  738.     ENDIF
  739.     DIR(MAIN)            = DEST$
  740.     DIR(DRAW)         = MakePath( DIR(MAIN), TR_DRAW )
  741.     DIR(CHART)         = MakePath( DIR(MAIN), TR_CHART )
  742.     DIR(SHOW)         = MakePath( DIR(MAIN), TR_SHOW )
  743.     DIR(PHOTO)         = MakePath( DIR(MAIN), TR_PHOTOPNT )
  744.     DIR(MOVE)         = MakePath( DIR(MAIN), TR_MOVE )
  745.     DIR(TRACE)         = MakePath( DIR(MAIN), TR_TRACE )
  746.     DIR(MOSAIC)     = MakePath( DIR(MAIN), TR_PROGRAMS )
  747.     DIR(SCANNERS)    = MakeDir(szScannerDir$)
  748.     DIR(FILTERS)     = MakePath( DIR(MAIN), TR_PROGRAMS )
  749.     DIR(FONTTT)     = MakeDir(szFontDir$)
  750. ''    szFontDir$ = ""
  751. END SUB
  752.  
  753. '** Add Redistributable files to the correct directory(s) in the copy list
  754. '*************************************************************************
  755. SUB AddRedistSection( szSection$) STATIC
  756.     IF bWindowsIsNetworked% OR bInstallNet% = FALSE THEN
  757.         '' Copy the redistributable files and dlls to windir or winsysdir
  758.         AddSectionFilesToCopyList szSection$, SrcDir$, szWWinDir$
  759.     ENDIF
  760.     IF bInstallNet% THEN
  761.         '' Store the redistributable files in REDIST until user installs
  762.         AddSectionFilesToCopyList szSection$, SrcDir$, MakePath(DIR(MAIN),TR_REDIST)
  763.     ENDIF
  764. END SUB
  765.  
  766.  
  767.